#include "difbtn.h"
#include <QPainter>
#include "global/myresource.h"
#include "commondef.h"

#define DIFBTN_W            250.0f
#define DIFBTN_H            60.0f

DifBtn::DifBtn(QWidget *parent,QString str,bool block) :
    BaseBtnWidget               (parent),
    m_block                     (block),
    m_strlever                  (str)
{
    m_size = QSizeF(DIFBTN_W,DIFBTN_H);
}

DifBtn::~DifBtn()
{

}

void DifBtn::paintEvent(QPaintEvent *)
{
    QPainter p(this);

    switch(m_state)
    {
    case NORMAL_IB:
    {
        p.setPen(QColor(255,255,255));
        p.drawImage(QRectF(QPointF(0.0f,0.0f),QSizeF(DIFBTN_W,DIFBTN_H)),
                    *MyResource::m_buttonpImage,BTN_IMAGE_RECT);
    }
        break;
    case PRESS_IB:
    {
        p.setPen(QColor(146,146,146));
        p.drawImage(QRectF(QPointF(0.0f,0.0f),QSizeF(DIFBTN_W,DIFBTN_H)),
                    *MyResource::m_buttonImage,BTN_IMAGE_RECT);
    }
        break;
    default:
        break;
    }

    p.drawText(QRectF(10,0,100,60),
               Qt::AlignCenter,
               m_strlever);

    if(m_block)
    {
        p.drawImage(QRectF(200,15,32,32),*MyResource::m_lockImage,QRectF(0.0f,0.0f,32.0f,32.0f));
    }
}
